const {Sequelize} = require('sequelize');
const {MYSQL_HOST,
  MYSQL_PWD,
  MYSQL_DB,
  MYSQL_USER,
  MYSQL_PORT} = require('../config/config.default')


const seq = new Sequelize(MYSQL_DB,MYSQL_USER,MYSQL_PWD,{
  host:MYSQL_HOST,
  dialect:'mysql',
  //数据库版本中文兼容
   define: {
    charset: 'utf8',
    collate: 'utf8_general_ci',
    timestamps: true
  },
})

seq.authenticate().then(() =>{
  console.log('数据库连接成功')
}).catch((err) =>{
  console.log('数据库连接失败',err)
})

module.exports = seq
